﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Collections;

namespace ECGServer
{
    class ECGServer
    {
        public static Hashtable PID_WorkStation;
        public static Hashtable PID_Client;
        public static Hashtable PID_ClientEndPoint;

        public static UdpClient ServerUDPSocket;
        public static TcpListener ServerTCPSocket;

        public ThreadReceiveMessage receiveMessageThread = new ThreadReceiveMessage();
        public ThreadReceiveData reveiveDataThread = new ThreadReceiveData();
        public ThreadManageConnection manageConnectionThread = new ThreadManageConnection();

        public ECGServer()
        {
            PID_WorkStation = new Hashtable();
            PID_Client = new Hashtable();
            PID_ClientEndPoint = new Hashtable();
            
            ServerUDPSocket = new UdpClient(new IPEndPoint(IPAddress.Any, Constants.UDP_PORT));
            ServerTCPSocket = new TcpListener(new IPEndPoint(IPAddress.Any, Constants.TCP_PORT));
            ServerUDPSocket.Client.ReceiveBufferSize = 500000;
            ServerUDPSocket.Client.SendBufferSize = 500000;
        }

        public void run()
        {
            ThreadReceiveMessage threadReceiveMessage = new ThreadReceiveMessage();
            threadReceiveMessage.run();
            ThreadReceiveData threadReceiveData = new ThreadReceiveData();
            threadReceiveData.run();
        }
    }
}
